//
//  HomeGoodsRecommendTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/30.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "HomeGoodsRecommendTableViewCell.h"

@interface HomeGoodsRecommendTableViewCell ()
@property (nonatomic,strong) GLGWImageView * goodsImageView;
@property (nonatomic,strong) GLGWLabel * stellNameLabel;
@property (nonatomic,strong) GLGWLabel * specLabel;
@property (nonatomic,strong) GLGWLabel * warehouseLabel;
@property (nonatomic,strong) GLGWButton * sotreNameBut;
@property (nonatomic,strong) GLGWLabel * piceLabel;
@property (nonatomic,strong) GLGWButton * synchronousLabel;
@end

@implementation HomeGoodsRecommendTableViewCell{
    
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
        }];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        //
        self.goodsImageView = [[GLGWImageView alloc] initInSuperView:bankgroundView];
        [self.goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(13));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(90)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(90)));
        }];
        self.goodsImageView.backgroundColor = kRandomColor;
        //
        self.stellNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
        [self.stellNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
//        self.stellNameLabel.text = @"三级螺纹钢 HRB400E 河钢";
//        self.stellNameLabel.backgroundColor = kRandomColor;
        //
        self.specLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
//        self.specLabel.backgroundColor = kRandomColor;
//        self.specLabel.text = @"φ6*12";
        [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNameLabel);
            make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        //
        self.warehouseLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
//        self.warehouseLabel.backgroundColor = kRandomColor;
//        self.warehouseLabel.text = @"北京京南国储库";
        [self.warehouseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(8));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
//            make.right.equalTo(self.stellNameLabel);
        }];
        [self.specLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
        [self.warehouseLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
        //
        self.sotreNameBut = [[GLGWButton alloc] initWithTitleLableFontType:SYSTEMFONT(12) titleColor:kColor_Rule_Yellow inSuperView:self.contentView];
        [self.sotreNameBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specLabel);
            make.top.equalTo(self.specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //
        self.piceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#FF374F"] inSuperView:bankgroundView];
//        self.piceLabel.text = @"¥3845/吨";
        [self.piceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNameLabel);
            make.top.equalTo(self.sotreNameBut.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        self.synchronousLabel = [[GLGWButton alloc] initWithTitle:@"立即同步" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor colorWithHexString:@"#FFFFFF"] theCornerRadius:3.0 backgroundColr:kColor_Rule_Yellow inSuperView:bankgroundView];
        [self.synchronousLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(60)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(25)));
        }];
    }
    return self;
}

-(void)setCarteListmodel:(HomecategoryproductinfosModel_CategoryProductInfos *)carteListmodel{
    _carteListmodel = carteListmodel;
    [self.goodsImageView sd_setImageWithURL:[NSURL URLWithString:_carteListmodel.imageUrl] placeholderImage:[UIImage imageNamed:@"ff"]];
    //
    self.stellNameLabel.text =[NSString stringWithFormat:@"%@ %@ %@",koString(_carteListmodel.productName),koString(_carteListmodel.productMaterial),koString(_carteListmodel.factoryName)];
    //
    self.specLabel.text = _carteListmodel.specifications;
    //
    self.piceLabel.text = [NSString stringWithFormat:@"¥%.2f/吨",_carteListmodel.unitPrice];
    //
    self.warehouseLabel.text = _carteListmodel.storehouseName;
    //
    if (_carteListmodel.shopName.length>0) {
        NSMutableDictionary *attribtDic = [NSMutableDictionary dictionary];
        attribtDic[NSUnderlineStyleAttributeName] = [NSNumber numberWithInteger:NSUnderlineStyleSingle];
        attribtDic[NSForegroundColorAttributeName] = kColor_Rule_Yellow;
        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:_carteListmodel.shopName attributes:attribtDic];
        [self.sotreNameBut setAttributedTitle:attribtStr forState:UIControlStateNormal];
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
